import openpyxl

myBook=openpyxl.load_workbook('城市排名表.xlsx',data_only=True)
mySheet=myBook.active

myRows=list(mySheet.values)[1:]
myList=[]
for myRow in myRows:
	myList+=str(myRow[1]).split('、')
myDict={}
for myName in myList:
	if myName in myDict.keys():
		myDict[myName]+=1
	else:
		myDict[myName]=1
myNewList=[]
for myName,myIndex in zip(myDict.keys(),myDict.values()):
	myNewList+=[[myName,myIndex]]

mySortList=sorted(myNewList,key=lambda x:x[1],reverse=True)
myCellValue=''
for myName in mySortList:
	myCellValue+=str(myName[0])+'('+str(myName[1])+'次)'+'、'
mySheet.append(['出现次数最多的城市',myCellValue])
myBook.save('结果表-城市排名表.xlsx')